<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>订单管理</title>
    <link rel="stylesheet" type="text/css" href="../../lib/pagination/style/pagination.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/base.css"/>
    <link rel="stylesheet" type="text/css" href="/css/base/base.css?20201106.1"/>
    <link rel="stylesheet" type="text/css" href="../../css/news/center.css"/>
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <link rel="stylesheet" href="/lib/laydate/skins/default/laydate.css">
    <script type="text/javascript" src="../../js/news/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="../../js/news/page.js"></script>
    <script src="../../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/layer/layer.js?20201106"></script>
    <script src="../../lib/laydate/laydate.js"></script>

    <style>
        * {font-family: "Microsoft Yahei" !important;}
        .header{
            margin-top: 15px;
            height: 40px;
        }
        .header .title{
            margin-left: 22px;
        }
        .header span{
            float: none;
            /*margin-top: 9px;*/
            font-size: 22px;
            color: #333;
            display: inline-block;
            margin-left: 10px;
            vertical-align: middle;
            margin-top: -6px;
        }
        .content_label{
            line-height: 28px;
            font-size: 15px;
            color: rgb(111, 111, 111);
        }
        .content_label ul li{
            height: 16px;
            line-height: 16px;
            padding: 5px 12px;
            margin: 25px 0px;
            font-size: 15px;
            border-radius: 3px;
            display: inline;
        }
        .content_label ul{
            margin: 15px 0;
        }

        .pagediv table thead {
            background: white;
            line-height: 40px;
            border-bottom: 1px #dddddd solid;
            font-size: 13pt;
            color: #2F5C8F;
            font-weight: bold;
            height: 50px;
            border: 0px;
        }
        .pagediv tr:hover {
            background-color: #D3E7FA;
        }
        .pagediv tr:nth-child(odd) {
            background-color: #F6F7F9;
        }
        .pagediv tr:nth-child(odd) {
            background-color: #F6F7F9;
        }
        .queries{
            padding: 10px 20px;
            height: 40px;
        }
        #pageTbody tr{
            height: 40px;
        }
        .editAndDelete2{
            color: red;
        }
        .editAndDelete1 .editAndDelete0{
            color: #2b7fe0;
        }
        #pop-up{
            height: 100%;
            position: fixed;
            top: -2px;
            right: -600px;
            display: none;
        }
        #keyWords{
            width: 130px;
            height: 30px;
            padding-left: 5px
        }
        .index_content_1 .one{
            color: white;
            padding: 4px;
        }
        .index_content_2 .one{
            color: white;
            padding: 4px;
        }

        #add_Excel{
            width: 120px;
            height: 30px;
            border: none;
            color: #fff;
            cursor: pointer;
            padding: 4px;
            padding-left: 35px;
            background-image: url(../../img/import/import.png);
            margin-top: -4px ;
        }
        #customerExport{
            background-image: url(../../img/import/export.png);
            width: 120px;
            height: 30px;
            border: none;
            color: #fff;
            cursor: pointer;
            padding: 4px;
            padding-left: 35px;
            margin-top: -4px ;
        }
        .one{
            width: 120px;
            height: 30px;
            border: none;
            color: #fff;
            cursor: pointer;
            padding: 5px;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
</head>
<body>
<!--head开始-->
<div class="header">
    <div class="title">
        <img src="/img/commonTheme/${sessionScope.InterfaceModel}/flow_run_title.png"><span style="">订单管理</span>
        <hr style="background-color: black"/>
    </div>
</div>
<div class="queries">
    <label>
        <input  placeholder="请输入订单名称" type="text" id="keyWords" style="border-radius: 3px;margin-bottom: 2px;"/>
        <button  type="button" class="one" id="query_btn" style="width: 120px">
            <img src="../../img/workflow/worksearch1.png" style="margin-right: 8px;margin-bottom: 2px;"/>查询
        </button>
        <input  type="button" class="inquire_btn" value="导出" id="customerExport" onclick="clicked1();"/>
        <input  type="button" class="inquire_btn" value="导入" id="add_Excel" onclick="clicked2()"/>
        <button  type="button" class="one" id="add_btn" style="width: 120px;" onclick="javascript:window.location.href='/order/addOrders';">
            <img src="../../img/mywork/newbuildworjk1.png" style="margin-right: 8px;margin-bottom: 2px;"/>新建
        </button>
    </label>
</div>
<div id="pagediv">

</div>

</body>
<script>
    var pageObj ;
    //tab切换
    $('.clearfix').on('click','li',function(){
        $(".clearfix li").removeClass("change");
        $(this).addClass('change');
        if($(this).attr('id')=='biaodan'){
            $('.news').html('<fmt:message code="workflow.th.tablesort" />');
            $('.flow_img').attr('src','/img/commonTheme/${sessionScope.InterfaceModel}/form_img.png');
            $('.tab_tone').css("display","block");
            $('.tab_ttwo').css("display","none");
            $('.sort_liucheng h1').html('<fmt:message code="workflow.th.tablelist" />');
            $('.new_liucheng').attr('data-numtrue',1)

        }else {
            $('.news').html('<fmt:message code="workflow.th.process" />');
            $('.flow_img').attr('src','/img/commonTheme/${sessionScope.InterfaceModel}/flow_img.png');
            $('.tab_ttwo').css("display","block");
            $('.tab_tone').css("display","none");
            $('.sort_liucheng h1').html('<fmt:message code="workflow.th.processlist" />');
            $('.new_liucheng').attr('data-numtrue',2)
        }
    });
    //        tab切换
    $(".content_label").on("click","li",function(){
        $(this).siblings('li').removeClass("active");
        $(this).addClass('active');
        if($(this).attr('class')=='index_content_1'){
            $('.main').find('iframe').prop('src','/..../');
        }else if($(this).attr('class')=='index_content_2'){
            $('.main').find('iframe').prop('src','/..../');
        }else{
            $('.main').find('iframe').prop('src','/..../');
        }
    });
    $(function () {
        var startTime=new Date().Format('yyyy-MM');
        //select 根据ajax绑定数据 循环显示
        $.ajax({
            url: "/customer/selectByStatus",
            type:'get',
            dataType:"JSON",
            success:function(data){
                var str='<li >客户状态:</li>';
                for (var i=0;i<data.object.length;i++){
                    str += '<li codeId="'+data.object[i].codeId+'">'+data.object[i].codeName+'</li>'
                }
                $('.index_content_1').html(str);

            }
        })
        $.ajax({
            url: "/customer/selectBySource",
            type:'get',
            dataType:"JSON",
            success:function(data){
                var str='<li >客户来源:</li>';
                for (var i=0;i<data.obj.length;i++){
                    str += '<li codeId="'+data.obj[i].codeId+'">'+data.obj[i].codeName+'</li>'
                }
                $('.index_content_2').html(str);

            }
        })
        $.ajax({
            url: "/customer/selectByLevel",
            type:'get',
            dataType:"JSON",
            success:function(data){
                var str='<li >客户级别:</li>';
                for (var i=0;i<data.object.length;i++){
                    str += '<li codeId="'+data.object[i].codeId+'">'+data.object[i].codeName+'</li>'
                }
                $('.index_content_3').html(str);
            }
        })
        var screenwidth = document.documentElement.clientWidth;
        // console.log(screenwidth*0.9)
        if (screenwidth  > 2200) {
            var nums = screenwidth * 0.97;
            var sumwidth = screenwidth * 0.97 + 'px';
        } else {
            var nums = 800;
            var sumwidth = '1250px';
        }
        var width0 = nums * 0.105 + 'px';
        var width1 = nums * 0.065 + 'px';
        var width2 = nums * 0.065 + 'px';
        var width3 = nums * 0.065 + 'px';
        var width4 = nums * 0.045 + 'px';
        var width5 = nums * 0.065 + 'px';
        var width6 = nums * 0.065 + 'px';
        pageObj=$.tablePage('#pagediv',sumwidth,[
            {
                width:width0,
                title:'订单名称',
                name:'orderName',
                selectFun:function (n,obj) {
                    if(obj.orderName==undefined){
                        return " "
                    }else{
                        return obj.orderName;
                    }
                }
            },
            {
                width:width1,
                title:'订单状态',
                name:'status',
                selectFun:function (n,obj) {
                    if(obj.status==undefined){
                        return " "
                    }else if(obj.status==0){
                        return "下单";
                    }else if(obj.status==1){
                        return "发货";
                    }else if(obj.status==2){
                        return "完成";
                    }
                }
            },
            {
                width:width2,
                title:'客户名称',
                name:'customerId',
                selectFun:function (n,obj) {
                    if(obj.customerId==undefined){
                        return " "
                    }else{
                        return obj.customerName;
                    }
                }
            },
            {
                width:width3,
                title:'合同名称',
                name:'contractId',
                selectFun:function (n,obj) {
                    if(obj.contractId==undefined){
                        return " "
                    }else{
                        return obj.contractName;
                    }
                }
            },
            {
                width:width4,
                title:'创建人',
                name:'creator',
                selectFun:function (n,obj) {
                    if(obj.creator==undefined){
                        return " "
                    }else{
                        return obj.creator;
                    }
                }
            },
            {
                width:width5,
                title:'创建时间',
                name:'createTime',
                selectFun:function (n,obj) {
                    if(obj.createTime==undefined){
                        return " "
                    }else{
                        return obj.createTime;
                    }
                }
            },
            {
                width:width6,
                title:'操作',
                name:'orgAddress'
            }
        ],function (me) {
//            me.obj.codeId=$('[name="type"]').val();
            me.data.pageSize=10;
            //1显示  // 2不显示  //不写fn这个属性就是全显示
            me.init("/order/insearchOrder",[
                {name:'详情'},
                {name:'编辑'},
                // {name:'跟进'},
                {name:'删除'},
            ],function () {

                $('#query_btn').click(function () {
                    var keyWords=$('#keyWords').val();
                    me.data.orderName = keyWords;
                    me.init("/order/insearchOrder");

                })
                $(".content_label").on("click","li",function(){
                    me.data.customerStatus = $('.index_content_1 .active').attr('codeId');
                    me.data.customerFrom = $('.index_content_2 .active').attr('codeId');
                    me.data.customerLevel = $('.index_content_3 .active').attr('codeId');
                    me.init("/order/insearchOrder");
                })
                $('.operation tr').eq(0).css('background-color','#FFFFFF')
            });
        });

        // 事件绑定处理
//        $('#pagediv').on('click','[name="all"]',function(){//全选
//            if($(this).is(':checked')){
//                $('#pageTbody').find('input[type=checkbox]').prop('checked',true)
//            }else {
//                $('#pageTbody').find('input[type=checkbox]').removeProp('checked')
//            }
//        });
//      根据id编辑数据
        $('#pageTbody').on('click','.editAndDelete1',function(){
            var orderId = pageObj.arrs[$(this).attr('data-i')].orderId;
            window.location.href = '/order/updateOrder?orderId='+orderId;
        });
//       根据id跟进数据
        $('#pageTbody').on('click','.editAndDelete0',function(){
            var orderId=pageObj.arrs[$(this).attr('data-i')].orderId;
            window.location.href = '/order/orderDetails?orderId='+orderId;
        });
        //ajax 根据orgId 删除数据
        $('#pageTbody').on('click','.editAndDelete2',function(){
            var orderId=pageObj.arrs[$(this).attr('data-i')].orderId;
            layer.confirm(qued,{
                btn: [sure,cancel], //按钮
                title:'确定删除？'
            }, function(){
                $.ajax({
                    type:'post',
                    url:'/order/deleteOrder',
                    dataType:'json',
                    data:{'orderId':orderId},
                    success: function (json) {
                        //第三方扩展皮肤
                        layer.msg('<fmt:message code="workflow.th.delsucess" />', {icon: 6});
                        location.reload();
                    }
                })
            }, function () {
                layer.closeAll();
            })
        });

    });
    //   导出Excel
    function clicked1() {
        window.location.href = "/order/orderExport"
    }
    function clicked2() {
        window.location.href = "/order/orderInser"
    }
</script>

</html>
